﻿#pragma execution_character_set("utf-8")
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QDir>
#include <QPixmap>
#include "QtAwesome.h"
QtAwesome* awesome;
MainWindow::    MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    init_Controls();
    init_Connections();


}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::init_Controls()
{
    awesome = new QtAwesome(ui->pbt_One);
    awesome->initFontAwesome();
    QFont font;
    font.setPixelSize(24);
    QVariantMap options;
    options.insert("anim", qVariantFromValue( new QtAwesomeAnimation(ui->pbt_One) ) );
    ui->pbt_One->setText("这是一个按钮")
        .setRadius(10)
        .setTextColor(QColor("lightGreen"))
        .setBackgroundColor(Qt::yellow)
        .setBorderColor(Qt::red)
        .setHoverColor(Qt::blue)
        .setIcon(awesome->icon(fa::beer, options), CPushButton::Right)
        .setFont(font);

    ui->pbt_One_2->setText("XXXXXXXXXXXXXXXXXXXXX")
        .setIcon(awesome->icon(fa::check));

    QVariantMap options2;
    options2.insert("color", QColor(Qt::green) );
    options2.insert("text-off", QString(fa::squareo) );
    options2.insert("color-off", QColor(Qt::red) );

    ui->pbt_One_3->setText("可选中的按钮")
        .setCheckable(true)
        .setIcon(awesome->icon(fa::checksquareo, options2))
        .setRadius(20);
}

void MainWindow::init_Connections()
{
    connect(ui->pbt_One,&CPushButton::clicked,this,&MainWindow::on_pbt_clicked);
}

void MainWindow::on_pbt_clicked()
{
    ui->pbt_One->setPressedColor(QColor(100,100,0));
}

